<?php

namespace app\content\controller;

use library\Controller;


/** 轮播图
 * Created by PhpStorm.
 * User: ycp
 * Date: 2019/11/18
 * Time: 21:07
 */

class Slide extends Controller
{
    protected $table = 'lite_slideshow';

    //轮播图首页
    public function index()
    {
        $this->type = config('data.image_type');
        $this->title = '轮播图管理';
        $where = ['is_deleted' => '0'];
        $this->_query($this->table)->like('name')->where($where)->page();
    }

    //添加轮播图
    public function add()
    {
        $this->type = config('data.image_type');
        $this->applyCsrfToken();
        $this->_form($this->table, 'form');
    }

    public function edit()
    {
        $this->type = config('data.image_type');
        $this->applyCsrfToken();
        $this->_form($this->table, 'form');
    }

    public function del()
    {
        $this->applyCsrfToken();
        $this->_delete($this->table);
    }


    public function _form_filter(&$data)
    {
        if ($this->request->isGet()) {
        } elseif ($this->request->isPost()) {
            $data['pic'] = substr($data['pic'],strpos($data['pic'], 'upload/'));
            $data['url'] = trim($data['url']);
            $data['create_time'] = date('Y-m-d H:i:s');
        }
    }
}